package com.example.myapplication.windowlive;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.example.myapplication.R;
import com.example.myapplication.shortvideo.utils.DisplayUtils;

/**
 * @author: rongfeng
 * @date: 2021/1/11
 * @description 小窗口直播
 */
public class WindowLiveView extends TouchMoveView implements View.OnClickListener {
    private View mView;
    private RelativeLayout mRootView;
    private ImageView img_close, img_mute;

    public WindowLiveView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mView = LayoutInflater.from(getContext()).inflate(R.layout.view_window_live, this);
        init();
    }

    private void init() {
        mRootView = mView.findViewById(R.id.rl_root);
        img_close = mView.findViewById(R.id.img_close);
        img_mute = mView.findViewById(R.id.img_mute);
        initWindowSize(true);
        mRootView.setOnTouchListener(this);
        img_close.setOnClickListener(this);
        img_mute.setOnClickListener(this);
    }

    private void initWindowSize(boolean isPc) {
        RelativeLayout.LayoutParams layoutParams = (LayoutParams) mRootView.getLayoutParams();
        if (isPc) {
            layoutParams.width = DisplayUtils.dp2px(160);
            layoutParams.height = DisplayUtils.dp2px(120);
        } else {
            layoutParams.width = DisplayUtils.dp2px(119);
            layoutParams.height = DisplayUtils.dp2px(212);
        }
        mRootView.setLayoutParams(layoutParams);
    }


    @Override
    public void onClick(View v) {
        if (v == img_close) {

        } else if (v == img_mute) {

        }
    }
}
